﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Config_App
{
    /// <summary>
    /// stellt eine virtuelle PB für die OCR bereit
    /// </summary>
    class _cls_PB_Stub
    {
        /// <summary>
        /// Zeichnet ein zeichen auf die virtuelle PB
        /// </summary>
        /// <param name="c">Zeichen welches gezeichnet werden soll</param>
        /// <param name="fontName">Schriftart</param>
        /// <param name="size">Größe</param>
        /// <param name="italic">Kursiv?</param>
        /// <param name="s">Ausmaße der Zeichnung</param>
        /// <returns></returns>
        public static Bitmap DrawLetter(char c, string fontName, float size, bool italic, Size s)
        {
            int width = s.Width;
            int height = s.Height;
            Brush blackBrush = new SolidBrush(Color.Black);
            Brush whiteBrush = new SolidBrush(Color.White);

            // create new image
            Bitmap image = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            // create graphics
            Graphics g = Graphics.FromImage(image);

            // fill rectangle
            g.FillRectangle(whiteBrush, 0, 0, width, height);

            // draw letter
            string str = new string(c, 1);
            Font font = new Font(fontName, size, (italic) ? FontStyle.Italic : FontStyle.Regular);
            g.DrawString(str, font, blackBrush, new Rectangle(0, 0, width, height));

            g.Dispose();
            font.Dispose();
            blackBrush.Dispose();
            whiteBrush.Dispose();

            return image;
        }
    }
}
